package com.ysq.track.view.panel;

import javax.swing.*;
import java.awt.*;
import java.net.URL;

public class DesFrameTmp extends JFrame {

    JTabbedPane desMainPanel;
    JPanel encryptPanel;
    JPanel decryptPanel;

    ImageIcon icon = createImageIcon("middle.png");

    public DesFrameTmp() {
        this.setTitle("加密/解密工具");
        this.setLayout(new GridLayout(1,3,10,10));
        this.setSize(400, 400);

        desMainPanel = new JTabbedPane();


        JButton encBtn = new JButton();
        encBtn.setSize(70, 25);
        encBtn.setName("加密");

        JButton decBtn = new JButton();
        decBtn.setSize(70, 25);
        decBtn.setName("解密");


        desMainPanel.add(encBtn);

        desMainPanel.add(decBtn);


        //layoutComponents();

        this.setContentPane(desMainPanel);
        this.setVisible(true);

    }

    private void layoutComponents() {
        encryptPanel = new JPanel();

        desMainPanel.addTab("加密", icon, encryptPanel, "加密1");

        decryptPanel = new JPanel();
        desMainPanel.addTab("解密", icon, decryptPanel, "解密");
        setLayout(new GridLayout(1, 1));
        add(desMainPanel);

    }

    private ImageIcon createImageIcon(String path) {
        URL url = DesFrameTmp.class.getResource(path);
        if (url == null) {
            System.out.println("the image " + path + " is not exist!");
            return null;
        }
        return new ImageIcon(url);
    }

    /**
     * @param args
     */
    public static void main(String[] args) {

        System.out.println("start ... ");

        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                //JFrame.setDefaultLookAndFeelDecorated(true);// 将组建外观设置为Java外观
                DesFrameTmp frame = new DesFrameTmp();


                // new TabComponentsDemo().runTest();
            }
        });
    }

}